package cn.wh.builder;

import cn.wh.mapping.BoundSql;
import cn.wh.mapping.ParameterMapping;
import cn.wh.mapping.SqlSource;
import cn.wh.session.Configuration;

import java.util.List;

/**
 * @Author wh
 * @Description 静态sql 源码
 * @Date 2023/2/13 15:40
 * @Version 1.0
 **/
public class StaticSqlSource implements SqlSource {


    private String sql;

    private List<ParameterMapping> parameterMappings;

    private Configuration configuration;

    public StaticSqlSource(Configuration configuration, String sql){
        this(configuration, sql, null);
    }

    public StaticSqlSource(Configuration configuration, String sql,  List<ParameterMapping> parameterMappings) {
        this.sql = sql;
        this.parameterMappings = parameterMappings;
        this.configuration = configuration;
    }


    @Override
    public BoundSql getBoundSql(Object parameterObject) {
        return new BoundSql(configuration, sql, parameterMappings, parameterObject);
    }
}
